package com.df.tank;

import java.awt.*;

public class Explode {
    public static int WIDTH = ImageMgr.explodes[0].getWidth();
    public static int HEIGHT = ImageMgr.explodes[0].getHeight();
    private int x;
    private int y;
    private TankFrame tankFrame;
    private int index = 0;
    private boolean living = true;
    public Explode(int x, int y,TankFrame tankFrame) {
        this.x = x;
        this.y = y;
        this.tankFrame = tankFrame;
        tankFrame.explodes.add(this);
        new Thread(()->new Audio("audio/explode.wav").play()).start();
    }

    public void paint(Graphics g) {
        if (!living) return;
        g.drawImage(ImageMgr.explodes[index++], this.x, this.y, null);
        if (index >= ImageMgr.explodes.length) {
            index = 0;
            living = false;
        }
    }
}
